package com.cloudcc.mobile.view.activity;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import android.os.Bundle;
import android.text.Html;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.OnClick;

import com.cloudcc.cloudframe.util.PackageUtils;
import com.cloudcc.cloudframe.util.StringUtils;
import com.cloudcc.mobile.R;
import com.cloudcc.mobile.view.base.BaseActivity;

/**
 * 关于cloudcc
 * 
 * @author Administrator
 * 
 */
public class CloudccActivity extends BaseActivity {

	@Bind(R.id.tv1) TextView tvCloudcc;
	@Bind(R.id.tv2) TextView tvVersionName;
	
	
	@Override
	public void init(Bundle savedInstanceState) {
		super.init(savedInstanceState);
		String fromAssets = getFromAssets();
		tvCloudcc.setText(Html.fromHtml(fromAssets));
		// 版本号
		String versionName = PackageUtils.getVersionName(mContext);
		tvVersionName.setText(StringUtils.isBlank(versionName) ? StringUtils.EMPTY
				: "Version:" + versionName);
	}

	@Override
	public int getLayoutId() {
		return R.layout.cloudcc;
	}
	
	@OnClick(R.id.back)
	public void clickBack(){
		finish();
	}
	
	/* 
     * 获取html文件 
     */  
    public String getFromAssets() {  
        try {  
            InputStreamReader inputReader = new InputStreamReader(  
                    getResources().getAssets().open("company.txt"));  
            BufferedReader bufReader = new BufferedReader(inputReader);  
            String line = "";  
            String Result = "";  
            while ((line = bufReader.readLine()) != null)  
                Result += line;  
            return Result;  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
        return "";  
    } 
}
